﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>制度文件</title>
    <link href="../demo.css" rel="stylesheet" type="text/css" />
    <script src="../../../SFramework/boot.js"></script>
</head>
<body>
    <input id="category_id" name="category_id" shownullitem="true" onvaluechanged="onDeptChanged"
           class="mini-treeselect" style="width: 35%;" url="/extendpage/data/jsondata.aspx?entity=t_system_category&type=1" expandonload="0" value="华商联集团规章制度" textfield="category_name" valuefield="id" parentfield="parent_id" />

    <div id="datagrid1" class="mini-datagrid" style="width:100%;height:400px;" allowresize="true" onrowdblclick="rowdblclick" pagesize="500" showpager="false"
         url="/extendpage/data/jsondata.aspx?entity=v_t_system_file&type=1&order=add_time&desc=No" idfield="id" multiselect="true">
        <div property="columns">
            <div field="institution_name" width="280" headeralign="center" allowsort="true">制度类型</div>
            <div field="institution_id" name="institution_id" width="500" headeralign="center" allowsort="true" visible="false">ID</div>
            <div field="ext" name="ext" width="500" headeralign="center" allowsort="true" visible="false"></div>
            <div name="action" width="100" headeralign="center">查看文件</div>
        </div>
    </div>
</body>
</html>
<script>
    mini.parse();
    var grid = mini.get("datagrid1");
    grid.load();

    grid.on("drawcell", function (e) {
        var record = e.record,
        column = e.column;

        //action列，超连接操作按钮
        if (column.name == "action") {
            e.cellStyle = "text-align:center";
            e.cellHtml = '<a href="javascript:openClick(\'' + record.institution_id + '\',\'' + record.ext + '\')">查看</a>&nbsp; '
        }

    });




    function onDeptChanged(e) {
        var obj = mini.get("category_id");
        var grid = mini.get("datagrid1");
        grid.load({ condition: "category_id='" + obj.getValue() + "'" });
    }
    function rowdblclick(e) {
        var row = e.row
        //var index = grid.indexOf(row);
        if (".jpg,.gif,.bmp,.icon,.png".indexOf(row.ext) > -1) {
            mini.open({
                url: "/ExtendPage/files/file_manager.aspx?institution_id=" + row.institution_id,
                title: "查看文件", width: 1200, height: 600,
                onload: function () {

                },
                ondestroy: function (action) {
                    grid.reload();
                }
            });
        } else {
            mini.open({
                url: "/ExtendPage/files/file_manager.aspx?institution_id=" + row.institution_id,
                title: "查看文件", width: 500, height: 300,
                onload: function () {

                },
                ondestroy: function (action) {
                    grid.reload();
                }
            });
        }
    }
    function openClick(id,ext) {
        if (".jpg,.gif,.bmp,.icon,.png".indexOf(ext) > -1) {

            mini.open({
                url: "/ExtendPage/files/file_manager.aspx?institution_id=" + id,
                title: "查看文件", width: 1200, height: 600,
                onload: function () {

                },
                ondestroy: function (action) {
                    grid.reload();
                }
            });
        } else {
            mini.open({
                url: "/ExtendPage/files/file_manager.aspx?institution_id=" + id,
                title: "查看文件", width: 500, height: 300,
                onload: function () {

                },
                ondestroy: function (action) {
                    grid.reload();
                }
            });
        }
    }

    // $(document).ready(
    //     function () {
    //         fnGetSingleData("t_sys_files", "REPLACE(([path]+'\'+name),'\','/') in (select value from dbo.ufn_split_string((select max(files_url) from v_t_system_file where category_id='" + getPar("category_id") + "'),',') t )");
    //     }
    //)
</script>
